--
-- Description: script to create the FilesEvents table.
-- This table holds the many to many relation ship between files and events.
-- Date created: 17 Apr 2008
--

set ANSI_NULLS on
set QUOTED_IDENTIFIER on
go

if not exists 
(
    select * 
    from dbo.sysobjects
    where id = object_id(N'[dbo].[FilesEvents]')
    and objectproperty(id, N'IsUserTable') = 1
)
begin
    create table [dbo].[FilesEvents]
    (
        [FileID] int not null
        , [EventID] bigint not null
        , [EventTypeID] smallint not null
        constraint [PK_FilesEvents] primary key clustered
        (
            [FileID] asc
            , [EventID] asc
            , [EventTypeID] asc
        ) on [primary]
    ) on [primary]

    print ''
    print '*************************************************************************************'  
    print 'Created table [dbo].[FilesEvents]'
    print '*************************************************************************************'  
    print ''
end
else
begin
    print ''
    print '*************************************************************************************'  
    print 'Table [dbo].[FilesEvents] already exists.'
    print '*************************************************************************************'  
    print ''
end
